import mongoose from '../dbHelper';
import {defaultSchemaExtend, defaultSchemaOptions} from "../config/index";

const Schema = mongoose.Schema;

const DlyAdminMenuSchema = new Schema(Object.assign({
    pid: {
        type: String,
        default: '0',
        required: true
    },
    title: {
        type: String,
        required: true
    },
    icon: String,
    path: {
        type: String,
        required: true
    },
    component: {
        type: String,
        // 如果type=1必填
        required: function () {
            return this.type;
        }
    },
    iframeLink: String,
    permission: String,
    affix: Number,
    isHide: {
        type: Number,
        required: true
    },
    isKeep: Number,
    sort: Number,
    type: {
        type: Number,
        required: true
    }
 
}, defaultSchemaExtend), defaultSchemaOptions);

const DlyAdminMenu = mongoose.model('DlyAdminMenu', DlyAdminMenuSchema, 'DlyAdminMenus');

export default DlyAdminMenu